<?php

namespace app\models;

use Faker\Provider\Base;
use Yii;

/**
 * This is the model class for table "we_user".
 *
 * @property integer $id
 * @property string $openid
 * @property string $nickname
 * @property integer $sex
 * @property string $language
 * @property string $city
 * @property string $province
 * @property string $country
 * @property string $headimgurl
 * @property string $created_at
 * @property string $updated_at
 * @property integer $created_by
 * @property integer $updated_by
 */
class WeUser extends BaseModel
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'we_user';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['openid', 'nickname', 'sex', 'language', 'city', 'province', 'country', 'headimgurl'], 'required'],
            [['sex', 'created_by', 'updated_by'], 'integer'],
            [['created_at', 'updated_at'], 'safe'],
            [['openid'], 'string', 'max' => 64],
            [['nickname', 'language', 'city', 'province', 'country'], 'string', 'max' => 32],
            [['headimgurl'], 'string', 'max' => 256],
            ['openid', 'unique']//不重复保存同一用户
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'openid' => '开放id',
            'nickname' => '昵称',
            'sex' => '性别',
            'language' => '语言',
            'city' => '城市',
            'province' => '省份',
            'country' => '国家',
            'headimgurl' => '头像',
            'created_at' => '创建时间',
            'updated_at' => '更新时间',
            'created_by' => '创建者',
            'updated_by' => '更新者',
        ];
    }
}
